
<script>
export default {
    options: { styleIsolation: "shared" },
	globalData:{
		isLogin: false,
		defaultAvatar: 'https://bac-miniprogram.oss-cn-beijing.aliyuncs.com/images/member/member_card_img.png',
	},
	onShow() {
		this.globalData.isLogin = Boolean(uni.getStorageSync('userToken'))
		
	}
}; 
</script>
<script setup>
	import { onLaunch,onShow } from "@dcloudio/uni-app"
	import { useStore } from "vuex";
	const store = useStore();
	onLaunch((options)=>{
		uni.hideTabBar();
		store.commit('setNavigatorName',options.path)
		let statusHeight = uni.getSystemInfoSync()['statusBarHeight'];
		uni.setStorageSync('advertise',false)
		store.commit('setBarHeight',statusHeight)
		// 计算头部高度
		let titleBarHeight = (uni.getMenuButtonBoundingClientRect().top - statusHeight) * 2 +
		     uni.getMenuButtonBoundingClientRect().height;
		let headerHeight = statusHeight + titleBarHeight;
		store.commit('setHeaderHeight',headerHeight);
		
		// 保存用户信息
		if(uni.getStorageSync('userToken')) store.commit('setUserToken',uni.getStorageSync('userToken'))
		 
		uni.addInterceptor('navigateTo', { //监听跳转
			success() {
				watchRouter(arguments[1]);
			}
		});
		uni.addInterceptor('switchTab', { //监听跳转
			success() {
				watchRouter(arguments[1]);
			}
		});
	})
	
	const watchRouter = path =>{
		store.commit('setNavigatorName',path.url);
	}
</script>
<style >
</style>
